﻿Imports System
Imports System.IO
Imports System.Data.SqlServerCe
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.Common

Public Class DatabaseFactory

    'Dim conn As SqlCeConnection
    Public conn As New SqlCeConnection()
    Dim engine As SqlCeEngine
    Dim create_eqam_user = "CREATE TABLE eqam_user ( " & _
                           "     USER_ID          	NVARCHAR(32) NOT NULL, " & _
                           "     USER_FULL_NAME        	NVARCHAR(50) NULL, " & _
                           "     USER_ROLE          	NVARCHAR(20) NOT NULL, " & _
                           "     USER_NAME          	NVARCHAR(50) NULL, " & _
                           "     USER_PASSWORD      	NVARCHAR(50) NULL,  " & _
                           "     STATUS_CODE        	NVARCHAR(10) NOT NULL, " & _
                           "     ADD_BY             	NVARCHAR(32) NOT NULL, " & _
                           "     DATE_ADD       	    NUMERIC(20) NULL, " & _
                           "     TIME_ADD       	    NUMERIC(20) NULL, " & _
                           "     DATE_UPDATE    	    NUMERIC(20) NULL, " & _
                           "     TIME_UPDATE       	    NUMERIC(20) NULL, " & _
                           "     UPDATE_BY          	NVARCHAR(32) NULL, " & _
                           "     CONSTRAINT PK_EQAM_USER PRIMARY KEY NONCLUSTERED (USER_ID))  "

    Dim create_eqam_user_log = "CREATE TABLE eqam_user_log ( " & _
                           "     LOG_ID     	        BIGINT IDENTITY NOT NULL,     " & _
                           "     USER_NAME          	NVARCHAR(50) NULL, " & _
                           "     ADD_BY             	NVARCHAR(32) NOT NULL, " & _
                           "     DATE_ADD       	    NUMERIC(20) NULL, " & _
                           "     TIME_ADD       	    NUMERIC(20) NULL, " & _
                           "     DATE_UPDATE    	    NUMERIC(20) NULL, " & _
                           "     TIME_UPDATE       	    NUMERIC(20) NULL, " & _
                           "     UPDATE_BY          	NVARCHAR(32) NULL, " & _
                           "     CONSTRAINT PK_EQAM_USER_LOG PRIMARY KEY NONCLUSTERED (LOG_ID))  "

    Dim create_eqam_welder = "CREATE TABLE eqam_welder ( " & _
                           "     WELDER_ID          	NVARCHAR(32) NOT NULL, " & _
                           "     WELDER_NAME        	NVARCHAR(50) NULL, " & _
                           "     WELDER_COMPANY_CODE	NVARCHAR(20) NOT NULL, " & _
                           "     WELDER_COMPANY_NAME	NVARCHAR(50) NOT NULL, " & _
                           "     STATUS_CODE        	NVARCHAR(10) NOT NULL, " & _
                           "     ADD_BY             	NVARCHAR(32) NOT NULL, " & _
                           "     DATE_ADD       	    NUMERIC(20) NULL, " & _
                           "     TIME_ADD       	    NUMERIC(20) NULL, " & _
                           "     DATE_UPDATE    	    NUMERIC(20) NULL, " & _
                           "     TIME_UPDATE       	    NUMERIC(20) NULL, " & _
                           "     UPDATE_BY          	NVARCHAR(32) NULL, " & _
                           "     CONSTRAINT PK_EQAM_WELDER PRIMARY KEY NONCLUSTERED (WELDER_ID))  "

    Dim create_eqam_project = "CREATE TABLE eqam_project ( " & _
                            "     PROJECT_ID     	NVARCHAR(32) NOT NULL,     " & _
                            "     PROJECT_NAME   	NVARCHAR(50) NULL," & _
                            "     SUPERVISOR_NAME   NVARCHAR(50) NOT NULL," & _
                            "     SUPERVISOR_ID     NVARCHAR(32) NOT NULL,     " & _
                            "     STATUS_CODE    	NVARCHAR(10) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_PROJECT PRIMARY KEY NONCLUSTERED (PROJECT_ID)) "

    Dim create_eqam_project_welder_mapping = "CREATE TABLE eqam_project_welder_mapping( " & _
                            "     MAPPING_ID     	BIGINT IDENTITY NOT NULL,     " & _
                            "     PROJECT_ID   	    NVARCHAR(32) NULL," & _
                            "     WELDER_ID         NVARCHAR(32) NOT NULL," & _
                            "     CONSTRAINT PK_EQAM_PROJECT PRIMARY KEY NONCLUSTERED (MAPPING_ID)) "

    Dim create_eqam_coupon = "CREATE TABLE eqam_coupon ( " & _
                            "     COUPON_ID     	BIGINT IDENTITY NOT NULL,     " & _
                            "     S_COUPON_ID   	NVARCHAR(32) NULL," & _
                            "     COUPON_CODE     	NVARCHAR(100) NOT NULL,     " & _
                            "     COUPON_TYPE     	NVARCHAR(1) NOT NULL,     " & _
                            "     BARCODE          	NVARCHAR(100) NULL,     " & _
                            "     PARENT_COUPON_BARCODE  NVARCHAR(100) NULL,     " & _
                            "     WELDER_USER_ID    NVARCHAR(32) NOT NULL, " & _
                            "     PIPE_TUBE         NVARCHAR(4) NOT NULL, " & _
                            "     IS_COAX           NVARCHAR(1) NULL," & _
                            "     COAX             	NVARCHAR(10) NULL," & _
                            "     PROJECT_ID        NVARCHAR(32) NOT NULL," & _
                            "     WELD_MACHINE_ID   NVARCHAR(32) NULL," & _
                            "     WELD_MACHINE_NAME  NVARCHAR(50) NOT NULL,     " & _
                            "     MATERIAL          NVARCHAR(50) NOT NULL," & _
                            "     SIZE              NVARCHAR(50) NOT NULL," & _
                            "     THICKNESS         NVARCHAR(50) NOT NULL," & _
                            "     HEAT_NUMBER_ID_1    NVARCHAR(32) NOT NULL,     " & _
                            "     HEAT_NUMBER_NAME_1  NVARCHAR(50) NOT NULL,     " & _
                            "     HEAT_NUMBER_ID_2    NVARCHAR(32) NOT NULL,     " & _
                            "     HEAT_NUMBER_NAME_2  NVARCHAR(50) NOT NULL,     " & _
                            "     STATUS_CODE    	NVARCHAR(10) NOT NULL, " & _
                            "     REJECT_REASON     NVARCHAR(255) NULL, " & _
                            "     REMARKS           NVARCHAR(255) NULL, " & _
                            "     JOINT_TYPE_CODE_1 NVARCHAR(50)  NULL,     " & _
                            "     JOINT_TYPE_NAME_1 NVARCHAR(50)  NULL,     " & _
                            "     JOINT_TYPE_CODE_2 NVARCHAR(50)  NULL,     " & _
                            "     JOINT_TYPE_NAME_2 NVARCHAR(50)  NULL,     " & _
                            "     PDA_CODE          NVARCHAR(50)  NULL,     " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_COUPON PRIMARY KEY NONCLUSTERED (COUPON_ID)) "

    Dim create_eqam_coupon_system = "CREATE TABLE eqam_coupon_system ( " & _
                            "     SYSTEM_ID     	BIGINT IDENTITY NOT NULL,     " & _
                            "     S_SYSTEM_ID   	NVARCHAR(32) NULL," & _
                            "     COUPON_BARCODE    NVARCHAR(100) NOT NULL,     " & _
                            "     SYSTEM_TYPE_ID    NVARCHAR(32) NOT NULL,     " & _
                            "     PDA_CODE          NVARCHAR(50)  NULL,     " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_COUPON_SYSTEM PRIMARY KEY NONCLUSTERED (SYSTEM_ID)) "

    Dim create_eqam_weldlog_detail = "CREATE TABLE eqam_weldlog_detail( " & _
                            "     WELDLOG_DETAIL_ID BIGINT IDENTITY NOT NULL,     " & _
                            "     S_WELDLOG_DETAIL_ID   	NVARCHAR(32) NULL," & _
                            "     BARCODE           NVARCHAR(100) NOT NULL,     " & _
                            "     BARCODE_REF       NVARCHAR(100) NOT NULL,     " & _
                            "     SEQ              	NUMERIC(20) NULL, " & _
                            "     COUPON_CODE     	NVARCHAR(100) NOT NULL,     " & _
                            "     COUPON_TYPE     	NVARCHAR(1) NOT NULL,     " & _
                            "     WELDER_USER_ID    NVARCHAR(32) NOT NULL, " & _
                            "     WELD_DATE       	NUMERIC(20) NULL, " & _
                            "     WELD_TIME       	NUMERIC(20) NULL, " & _
                            "     QC_USER_ID        NVARCHAR(32) NULL, " & _
                            "     QC_DATE       	NUMERIC(20) NULL, " & _
                            "     QC_TIME       	NUMERIC(20) NULL, " & _
                            "     QC_STATUS     	NVARCHAR(10) NULL, " & _
                            "     REJECT_REASON     NVARCHAR(255) NULL, " & _
                            "     REPLACEMENT_ID    BIGINT NULL,     " & _
                            "     REJECT_BARCODE    NVARCHAR(100) NULL,     " & _
                            "     REPLACE_BARCODE   NVARCHAR(100) NULL,     " & _
                            "     REMARK            NVARCHAR(255) NULL, " & _
                            "     STATUS_CODE     	NVARCHAR(10) NOT NULL, " & _
                            "     SYSTEM_TYPE_ID    NVARCHAR(32) NOT NULL,     " & _
                            "     SYSTEM_TYPE_NAME  NVARCHAR(50) NOT NULL,     " & _
                            "     HEAT_NUMBER_ID_1    NVARCHAR(32) NOT NULL,     " & _
                            "     HEAT_NUMBER_NAME_1  NVARCHAR(50) NOT NULL,     " & _
                            "     HEAT_NUMBER_ID_2    NVARCHAR(32) NOT NULL,     " & _
                            "     HEAT_NUMBER_NAME_2  NVARCHAR(50) NOT NULL,     " & _
                            "     JOINT_TYPE_CODE_1 NVARCHAR(50) NOT NULL,     " & _
                            "     JOINT_TYPE_NAME_1 NVARCHAR(50) NOT NULL,     " & _
                            "     JOINT_TYPE_CODE_2 NVARCHAR(50) NOT NULL,     " & _
                            "     JOINT_TYPE_NAME_2 NVARCHAR(50) NOT NULL,     " & _
                            "     ZONE_ID     	    NVARCHAR(32) NOT NULL,     " & _
                            "     ZONE              NVARCHAR(50) NOT NULL,     " & _
                            "     PDA_CODE          NVARCHAR(50)  NULL,     " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_WELDLOG PRIMARY KEY NONCLUSTERED (WELDLOG_DETAIL_ID)) "

    Dim create_eqam_material = "CREATE TABLE eqam_material ( " & _
                            "     MATERIAL          NVARCHAR(50) NOT NULL,     " & _
                            "     STATUS_CODE    	NVARCHAR(10) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_MATERIAL PRIMARY KEY NONCLUSTERED (MATERIAL)) "

    Dim create_eqam_weld_size = "CREATE TABLE eqam_weld_size ( " & _
                            "     WELD_SIZE_ID      NVARCHAR(32) NOT NULL,     " & _
                            "     WELDER_ID         NVARCHAR(32) NOT NULL, " & _
                            "     PROJECT_ID        NVARCHAR(32) NULL, " & _
                            "     SIZE          	NVARCHAR(50) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     PRIMARY KEY (WELD_SIZE_ID)) "

    Dim create_eqam_tube_type = "CREATE TABLE eqam_tube_type ( " & _
                            "     TUBE_TYPE_ID      NVARCHAR(32) NOT NULL,     " & _
                            "     MATERIAL          NVARCHAR(50) NOT NULL,     " & _
                            "     SIZE              NVARCHAR(10) NOT NULL,     " & _
                            "     THICKNESS         NVARCHAR(10) NOT NULL,     " & _
                            "     STATUS_CODE    	NVARCHAR(10) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(20) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(32) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_TUBE_TYPE PRIMARY KEY NONCLUSTERED (TUBE_TYPE_ID)) "

    Dim create_eqam_system_type = "CREATE TABLE eqam_system_type ( " & _
                            "     SYSTEM_TYPE_ID    NVARCHAR(32) NOT NULL,     " & _
                            "     PROJECT_ID     	NVARCHAR(32) NOT NULL,     " & _
                            "     SYSTEM_TYPE_NAME  NVARCHAR(200) NOT NULL,     " & _
                            "     DRAWING_NUMBER    NVARCHAR(200) NULL,     " & _
                            "     STATUS_CODE    	NVARCHAR(10) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_SYSTEM_TYPE PRIMARY KEY NONCLUSTERED (SYSTEM_TYPE_ID)) "

    Dim create_eqam_heat_number = "CREATE TABLE eqam_heat_number ( " & _
                            "     HEAT_NUMBER_ID    NVARCHAR(32) NOT NULL,     " & _
                            "     PROJECT_ID     	NVARCHAR(32) NOT NULL,     " & _
                            "     HEAT_NUMBER_NAME  NVARCHAR(50) NOT NULL,     " & _
                            "     STATUS_CODE    	NVARCHAR(10) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_HEAT_NUMBER PRIMARY KEY NONCLUSTERED (HEAT_NUMBER_ID)) "

    Dim create_eqam_joint_type = "CREATE TABLE eqam_joint_type ( " & _
                            "     JOINT_TYPE_CODE   NVARCHAR(50) NOT NULL,     " & _
                            "     JOINT_TYPE_NAME   NVARCHAR(50) NOT NULL,     " & _
                            "     STATUS_CODE    	NVARCHAR(10) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_JOINT_TYPE_CODE PRIMARY KEY NONCLUSTERED (JOINT_TYPE_CODE)) "

    Dim create_eqam_reject_reason = "CREATE TABLE eqam_reject_reason ( " & _
                            "     REASON_ID     	NVARCHAR(32) NOT NULL,     " & _
                            "     REASON            NVARCHAR(50) NOT NULL,     " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_REJECT_REASON PRIMARY KEY NONCLUSTERED (REASON_ID)) "

    Dim create_eqam_zone = "CREATE TABLE eqam_zone ( " & _
                            "     ZONE_ID     	    NVARCHAR(32) NOT NULL,     " & _
                            "     ZONE              NVARCHAR(50) NOT NULL,     " & _
                            "     PROJECT_ID     	NVARCHAR(32) NOT NULL,     " & _
                            "     SEQ         	    NUMERIC(20) NOT NULL, " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_ZONE_ID PRIMARY KEY NONCLUSTERED (ZONE_ID)) "

    Dim create_eqam_weld_seq = "CREATE TABLE eqam_weld_seq ( " & _
                            "     SEQ_ID            BIGINT IDENTITY NOT NULL,     " & _
                            "     S_SEQ_ID   	    NVARCHAR(32) NULL," & _
                            "     PROJECT_ID     	NVARCHAR(32) NOT NULL,     " & _
                            "     ZONE     	        NVARCHAR(50) NOT NULL,     " & _
                            "     SEQ         	    NUMERIC(20) NOT NULL, " & _
                            "     BARCODE           NVARCHAR(100) NOT NULL,     " & _
                            "     PDA_CODE          NVARCHAR(50)  NULL,     " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_WELD_SEQ PRIMARY KEY NONCLUSTERED (SEQ_ID)) "

    Dim create_eqam_weld_replacement = "CREATE TABLE eqam_weld_replacement ( " & _
                            "     REPLACEMENT_ID        BIGINT IDENTITY NOT NULL,     " & _
                            "     S_REPLACEMENT_ID   	NVARCHAR(32) NULL," & _
                            "     REJECT_BARCODE        NVARCHAR(100) NULL,     " & _
                            "     REPLACE_BARCODE       NVARCHAR(100) NULL,     " & _
                            "     PROJECT_ID     	    NVARCHAR(32) NOT NULL,     " & _
                            "     PDA_CODE          NVARCHAR(50)  NULL,     " & _
                            "     ADD_BY         	NVARCHAR(32) NOT NULL, " & _
                            "     DATE_ADD       	NUMERIC(20) NULL, " & _
                            "     TIME_ADD       	NUMERIC(20) NULL, " & _
                            "     DATE_UPDATE    	NUMERIC(20) NULL, " & _
                            "     TIME_UPDATE       NUMERIC(20) NULL, " & _
                            "     UPDATE_BY      	NVARCHAR(32) NULL, " & _
                            "     CONSTRAINT PK_EQAM_WELD_REPLACEMENT PRIMARY KEY NONCLUSTERED (REPLACEMENT_ID)) "

    Dim create_eqam_weld_machine = "CREATE TABLE eqam_weld_machine ( " & _
                         "     PROJECT_WELD_MACHINE_ID  NVARCHAR(32) NOT NULL,     " & _
                         "     WELD_MACHINE_ID     	NVARCHAR(32)  NULL,     " & _
                         "     SERIAL_NUMBER         NVARCHAR(50) NULL,     " & _
                         "     WELD_MACHINE_MODEL    NVARCHAR(50) NULL,     " & _
                         "     CALIBRATION_DATE_ADD  NUMERIC(20) NULL, " & _
                         "     CALIBRATION_TIME_ADD  NUMERIC(20) NULL, " & _
                         "     PROJECT_ID     	    NVARCHAR(32) NULL,     " & _
                         "     STATUS         	    NVARCHAR(1) NULL, " & _
                         "     ADD_BY         	    NVARCHAR(32) NULL, " & _
                         "     DATE_ADD       	    NUMERIC(20) NULL, " & _
                         "     TIME_ADD       	    NUMERIC(20) NULL, " & _
                         "     DATE_UPDATE    	    NUMERIC(20) NULL, " & _
                         "     TIME_UPDATE           NUMERIC(20) NULL, " & _
                         "     UPDATE_BY      	    NVARCHAR(32) NULL, " & _
                         "     CONSTRAINT PK_EQAM_MACHINE_ID PRIMARY KEY NONCLUSTERED (PROJECT_WELD_MACHINE_ID)) "

    Dim a1 = "INSERT INTO eqam_project(PROJECT_ID, SUPERVISOR_NAME, SUPERVISOR_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, PROJECT_NAME, STATUS_CODE) " & _
                            " VALUES ('PROJECTA', 'Wendy', 'wendyId', 1, 20110607, 100000, 20110607, 100000, 1, 'MEMC', 'A')"
    Dim a2 = "INSERT INTO eqam_welder(ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , WELDER_NAME, WELDER_COMPANY_CODE, WELDER_COMPANY_NAME, WELDER_ID) " & _
                             " VALUES (1, 20110607, 100000, 20110607, 100000, 1, 'A', 'JASON', 'THEONE', 'THE ONE FORMULA', 2)"
    Dim a3 = "INSERT INTO eqam_welder(ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , WELDER_NAME, WELDER_COMPANY_CODE, WELDER_COMPANY_NAME, WELDER_ID) " & _
                             " VALUES (1, 20110607, 100000, 20110607, 100000, 1, 'A', 'BENNY', 'THEONE', 'THE ONE FORMULA', 3)"
    Dim a4 = "INSERT INTO eqam_user(USER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , USER_FULL_NAME, USER_ROLE, USER_NAME, USER_PASSWORD) " & _
                             " VALUES (1, 1, 20110607, 100000, 20110607, 100000, 1, 'A', 'admin', 'ENGINEER', 'admin','123456')"
    Dim a5 = "INSERT INTO eqam_user(USER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , USER_FULL_NAME, USER_ROLE, USER_NAME, USER_PASSWORD) " & _
                             " VALUES (2, 1, 20110607, 100000, 20110607, 100000, 1, 'A', 'Jason Wong', 'WELDER', 'jason','123456')"
    Dim a6 = "INSERT INTO eqam_user(USER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , USER_FULL_NAME, USER_ROLE, USER_NAME, USER_PASSWORD) " & _
                             " VALUES (3, 1, 20110607, 100000, 20110607, 100000, 1, 'A', 'Benny Ong', 'WELDER', 'benny','123456')"
    Dim a7 = "INSERT INTO eqam_material(MATERIAL, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('T304L', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"
    Dim a8 = "INSERT INTO eqam_material(MATERIAL, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('T306L', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"
    Dim a9 = "INSERT INTO eqam_tube_type(TUBE_TYPE_ID, MATERIAL, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , SIZE, THICKNESS) " & _
                             " VALUES ('A', 'T304L', 1, 20110607, 100000, 20110607, 100000, 1, 'A', '0.125', '0.405')"
    Dim a10 = "INSERT INTO eqam_tube_type(TUBE_TYPE_ID, MATERIAL, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , SIZE, THICKNESS) " & _
                             " VALUES ('B', 'T304L', 1, 20110607, 100000, 20110607, 100000, 1, 'A', '0.25', '0.540')"
    Dim a11 = "INSERT INTO eqam_tube_type(TUBE_TYPE_ID, MATERIAL, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE" & _
                             " , SIZE, THICKNESS) " & _
                             " VALUES ('C', 'T306L', 1, 20110607, 100000, 20110607, 100000, 1, 'A', '0.35', '0.640')"

    Dim a12 = "INSERT INTO eqam_system_type(SYSTEM_TYPE_ID, PROJECT_ID, SYSTEM_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('ST001', 'PROJECTA', 'System 1', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"

    Dim a13 = "INSERT INTO eqam_system_type(SYSTEM_TYPE_ID, PROJECT_ID, SYSTEM_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('ST002', 'PROJECTA', 'System 2', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"

    Dim a13a = "INSERT INTO eqam_system_type(SYSTEM_TYPE_ID, PROJECT_ID, SYSTEM_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('ST003', 'PROJECTA', 'System 3', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"

    Dim a13b = "INSERT INTO eqam_system_type(SYSTEM_TYPE_ID, PROJECT_ID, SYSTEM_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('ST004', 'PROJECTA', 'System 4', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"

    Dim a13c = "INSERT INTO eqam_system_type(SYSTEM_TYPE_ID, PROJECT_ID, SYSTEM_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('ST005', 'PROJECTA', 'System 5', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"

    Dim a14 = "INSERT INTO eqam_heat_number(HEAT_NUMBER_ID, PROJECT_ID, HEAT_NUMBER_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('H001', 'PROJECTA', 'Heat 1', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"

    Dim a15 = "INSERT INTO eqam_heat_number(HEAT_NUMBER_ID, PROJECT_ID, HEAT_NUMBER_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('H002', 'PROJECTA', 'Heat 2', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"

    Dim a16 = "INSERT INTO eqam_joint_type(JOINT_TYPE_CODE, JOINT_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('T', 'TUBE', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"
    Dim a17 = "INSERT INTO eqam_joint_type(JOINT_TYPE_CODE, JOINT_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('F', 'FITTING', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"
    Dim a18 = "INSERT INTO eqam_joint_type(JOINT_TYPE_CODE, JOINT_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('G', 'GLAND', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"
    Dim a19 = "INSERT INTO eqam_joint_type(JOINT_TYPE_CODE, JOINT_TYPE_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                             " VALUES ('V', 'VALVE', 1, 20110607, 100000, 20110607, 100000, 1, 'A')"
    Dim a20a = "INSERT INTO eqam_reject_reason(REASON, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('Misalignment', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a20b = "INSERT INTO eqam_reject_reason(REASON, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                                 " VALUES ('Concavity', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a20c = "INSERT INTO eqam_reject_reason(REASON, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('Convexity', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a20d = "INSERT INTO eqam_reject_reason(REASON, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('Bead width', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a20e = "INSERT INTO eqam_reject_reason(REASON, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('Discoloration', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a20f = "INSERT INTO eqam_reject_reason(REASON, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('Other', 1, 20110607, 100000, 20110607, 100000, 1)"

    Dim a21a = "INSERT INTO eqam_zone(ZONE_ID, ZONE, SEQ, PROJECT_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('A','A', 1, 'PROJECTA', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a21b = "INSERT INTO eqam_zone(ZONE_ID, ZONE, SEQ, PROJECT_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('B','B', 1, 'PROJECTA', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a21c = "INSERT INTO eqam_zone(ZONE_ID, ZONE, SEQ, PROJECT_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('C','C', 1, 'PROJECTA', 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a21d = "INSERT INTO eqam_zone(ZONE_ID, ZONE, SEQ, PROJECT_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('D','D', 1, 'PROJECTA', 1, 20110607, 100000, 20110607, 100000, 1)"

    Dim a22a = "INSERT INTO eqam_weld_size(WELD_SIZE_ID, PROJECT_ID, SIZE, WELDER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('1', 'PROJECTA', '1/8', 2, 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a22b = "INSERT INTO eqam_weld_size(WELD_SIZE_ID, PROJECT_ID, SIZE, WELDER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                                 " VALUES ('2', 'PROJECTA', '1/20', 2, 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a22c = "INSERT INTO eqam_weld_size(WELD_SIZE_ID, PROJECT_ID, SIZE, WELDER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('3', 'PROJECTA', '1/20', 3, 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a22d = "INSERT INTO eqam_weld_size(WELD_SIZE_ID, PROJECT_ID, SIZE, WELDER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('4', 'PROJECTA', '1/16', 3, 1, 20110607, 100000, 20110607, 100000, 1)"

    Dim a23a = "INSERT INTO eqam_weld_machine(WELD_MACHINE_ID, PROJECT_ID, SERIAL_NUMBER, WELD_MACHINE_MODEL, CALIBRATION_DATE_ADD, CALIBRATION_TIME_ADD, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('1', 'PROJECTA', 'SE-1', 'MODEL-1', 20110607, 100000, 1, 20110607, 100000, 20110607, 100000, 1)"
    Dim a23b = "INSERT INTO eqam_weld_machine(WELD_MACHINE_ID, PROJECT_ID, SERIAL_NUMBER, WELD_MACHINE_MODEL, CALIBRATION_DATE_ADD, CALIBRATION_TIME_ADD, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY) " & _
                             " VALUES ('2', 'PROJECTA', 'SE-2', 'MODEL-2', 20110607, 100000, 1, 20110607, 100000, 20110607, 100000, 1)"


    Dim createTableSqls() As String = {create_eqam_user, create_eqam_welder, create_eqam_project, create_eqam_coupon, create_eqam_material, create_eqam_tube_type, create_eqam_heat_number, create_eqam_joint_type, create_eqam_system_type, create_eqam_weldlog_detail, create_eqam_coupon_system, create_eqam_reject_reason, create_eqam_zone, create_eqam_weld_size, create_eqam_user_log, create_eqam_weld_seq, create_eqam_weld_replacement, create_eqam_project_welder_mapping, create_eqam_weld_machine}
    Dim tableNames() As String = {"eqam_user", "eqam_welder", "eqam_project", "eqam_coupon", "eqam_material", "eqam_tube_type", "eqam_heat_number", "eqam_joint_type", "eqam_system_type", "eqam_weldlog_detail", "eqam_coupon_system", "eqam_reject_reason", "eqam_zone", "eqam_weld_size", "eqam_user_log", "eqam_weld_seq", "eqam_weld_replacement", "eqam_project_welder_mapping", "eqam_weld_machine"}
    'Dim createDummyDataSqls() As String = {a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a13a, a13b, a13c, a14, a15, a16, a17, a18, a19, a20a, a20b, a20c, a20d, a20e, a20f, a21a, a21b, a21c, a21d, a22a, a22b, a22c, a22d, a23a, a23b}
    Dim createDummyDataSqls() As String = {a4}
    'Dim createDummyDataSqls() As String = {}

    '    CREATE TABLE Tool(
    '   ID BIGINT IDENTITY NOT NULL PRIMARY KEY, 
    '   Name VARCHAR(40) NOT NULL
    ')

    'Dim create_p_cust = "CREATE TABLE p_cust (ccdcust NVARCHAR(10) NOT NULL,cagent NVARCHAR(80) NULL,carea NVARCHAR(80) NULL,cname NVARCHAR(80) NULL," & _
    '                                "ycrlimit NUMERIC(15,2) NULL,CONSTRAINT PK_p_cust PRIMARY KEY NONCLUSTERED (ccdcust))"
    'Dim create_p_sales = "CREATE TABLE p_sales (ccdcust NVARCHAR(10) NOT NULL,dorder DATETIME NOT NULL,citmno NVARCHAR(20) NOT NULL, cdesc NVARCHAR(80) NOT NULL," & _
    '                               " cbarcode NVARCHAR(20) NULL,cmaxprc NVARCHAR(15) NULL, yprice NUMERIC(15,2), nqty NUMERIC(15,0) NULL, cuom NVARCHAR(10) NULL,ndisount1 NUMERIC(10,2) NULL,ndisount2 NUMERIC(10,2) NULL, " & _
    '                               " yttlprc NUMERIC(15,2) NULL, tadd DATETIME NULL, tmodify DATETIME NULL, CONSTRAINT PK_p_sales PRIMARY KEY NONCLUSTERED (ccdcust,dorder,citmno))"


    Public Sub New()
        Dim cmd As SqlCeCommand

        If (File.Exists(_DATABASE_NAME) = False) Then
            Try
                MessageBox.Show(_DATABASE_NAME & " does not exist !")
                'CREATE DATABASE
                engine = New SqlCeEngine("Data Source = " & _DATABASE_NAME)
                engine.CreateDatabase()

                connect()

                'cmd = conn.CreateCommand
                'cmd.CommandText = create_eqam_welder
                'cmd.ExecuteNonQuery()

            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
            End Try

        End If

        connect()
        Dim rdr As SqlCeDataReader

        Dim tableName As String
        Dim i As Integer = 0

        '''''''''''''''''''''''''''''''''''''''''''''
        '  ALTER FIELD
        '''''''''''''''''''''''''''''''''''''''''''''
        Try
            cmd = conn.CreateCommand()
            cmd.CommandText = "ALTER TABLE eqam_weldlog_detail ADD COLUMN ZONE_ID NVARCHAR(32)"

            rdr = cmd.ExecuteReader

        Catch ex As Exception
            'MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
        End Try

        Try
            cmd = conn.CreateCommand()
            cmd.CommandText = "ALTER TABLE eqam_weldlog_detail ADD COLUMN ZONE NVARCHAR(50)"

            rdr = cmd.ExecuteReader

        Catch ex As Exception
            'MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
        End Try
        '''''''''''''''''''''''''''''''''''''''''''''
        '  ~ END ALTER FIELD END ~
        '''''''''''''''''''''''''''''''''''''''''''''

        For Each tableName In tableNames
            Try
                cmd = conn.CreateCommand()
                cmd.CommandText = "SELECT * FROM " & tableName

                rdr = cmd.ExecuteReader

            Catch ex As Exception
                cmd = conn.CreateCommand
                cmd.CommandText = createTableSqls(i)
                cmd.ExecuteNonQuery()
            End Try
            i = i + 1
        Next

        If Globals._CREATE_DUMMY_DATA = True Then

            For Each sql In createDummyDataSqls
                Try
                    cmd = conn.CreateCommand
                    cmd.CommandText = sql
                    cmd.ExecuteNonQuery()
                Catch ex As Exception
                    Console.Write(ex.Message)
                End Try
            Next
        End If
    End Sub

    Public Sub connect()
        Try
            conn = New SqlCeConnection("Data Source = " & _DATABASE_NAME)
            conn.Open()

        Catch ex As Exception

            MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")

        End Try
    End Sub

    Public Sub disconnect()
        Try
            conn.Close()

        Catch ex As Exception

            MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")

        End Try
    End Sub

    Public Function execute_del_sql(ByVal SQL As String)
        Dim cmd As SqlCeCommand

        connect()
        cmd = conn.CreateCommand
        cmd.CommandText = SQL

        Try
            cmd.ExecuteNonQuery()
            disconnect()
            Return True

        Catch ex As Exception
            disconnect()
            MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
            Return False
        End Try

    End Function

    Public Function execute_Upd_sql(ByVal SQL As String)
        Dim cmd As SqlCeCommand

        connect()
        cmd = conn.CreateCommand
        cmd.CommandText = SQL

        Try
            cmd.ExecuteNonQuery()
            disconnect()
            Return True
        Catch ex As Exception
            disconnect()
            MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
            Return False
        End Try
    End Function

    Public Function execute_Ins_sql(ByVal SQL As String)
        Dim cmd As SqlCeCommand
        connect()
        cmd = conn.CreateCommand
        cmd.CommandText = SQL

        Try
            cmd.ExecuteNonQuery()
            disconnect()
            Return True
        Catch ex As Exception
            disconnect()
            MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
            Return False
        End Try
    End Function

    Public Sub listData(ByVal lstview As ListView, ByVal username As String)
        Dim cmd As SqlCeCommand
        Dim rdr As SqlCeDataReader
        Dim item As ListViewItem

        connect()
        Try
            cmd = conn.CreateCommand()
            cmd.CommandText = "SELECT * FROM " & username & ""

            rdr = cmd.ExecuteReader
            lstview.Items.Clear()
            While (rdr.Read)
                item = New ListViewItem
                item.Text = rdr.GetString(0)
                lstview.Items.Add(item)
            End While
            disconnect()
        Catch ex As Exception
            disconnect()
            MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
        End Try
    End Sub

    Public Function Chk_duplicate(ByVal SQL As String)
        Dim cmd As SqlCeCommand
        Dim rdr As SqlCeDataReader

        connect()
        Try
            cmd = conn.CreateCommand()
            cmd.CommandText = SQL
            rdr = cmd.ExecuteReader

            Return rdr.Read

        Catch ex As Exception
            disconnect()
            MsgBox(ex.Message, MsgBoxStyle.Critical, "EQAM")
        End Try

        Return 0
    End Function

    Public Function connectionStatus() As Boolean

        If (conn.State = ConnectionState.Open) Then
            connectionStatus = True
        Else
            connectionStatus = False
        End If

    End Function

    Public Sub showErrors(ByVal e As SqlCeException)

        Dim errorCollection As SqlCeErrorCollection = e.Errors

        Dim bld As String = ""
        Dim inner As Exception = e.InnerException
        Dim err As SqlCeError = Nothing

        For Each err In errorCollection
            bld = "Error Code: " & err.HResult.ToString("X")
            bld = bld & vbCrLf & "Message   : " & err.Message
            bld = bld & vbCrLf & "Minor Err.: " & err.NativeError
            bld = bld & vbCrLf & "Source    : " & err.Source
        Next

        Dim numPar As Integer

        For Each numPar In err.NumericErrorParameters
            If (0 <> numPar) Then
                bld = bld & ("\n Num. Par. : " + numPar)
            End If

        Next

        Dim errPar As String

        For Each errPar In err.ErrorParameters
            If (String.Empty <> errPar) Then
                bld = bld & ("\n Err. Par. : " + errPar)
            End If

        Next


        MessageBox.Show(bld)

    End Sub



End Class
